package cn.hcbycloud.common.jwt.config;

import cn.hcbycloud.common.jwt.properties.EncryptionKeyProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;

/**
 * @author gaoh
 * @desc 从文件中获取密钥信息
 * @date 2022年01月18日 下午 2:44
 */
@Configuration
@PropertySource(value = "classpath:key.properties" , ignoreResourceNotFound = true)
public class EncryptionKeyConfig {
    @Autowired
    private Environment environment;
    @Bean
    EncryptionKeyProperties getEncryptionKeyProperties() {
        EncryptionKeyProperties encryptionKeyProperties = new EncryptionKeyProperties();
        encryptionKeyProperties.setPrivateKey(environment.getProperty("key.privateKey"));
        encryptionKeyProperties.setPublicKey(environment.getProperty("key.publicKey"));
        return encryptionKeyProperties;
    }
}